﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using Tequila.AugmentedReality.Data;

namespace Tequila.AugmentedReality.Views
{
    public class CameraPoiView : Control
    {
        public CameraPoiView()
        {
            base.DefaultStyleKey = typeof (CameraPoiView);
            base.LayoutUpdated += CameraPoiView_LayoutUpdated;
        }

        void CameraPoiView_LayoutUpdated(object sender, System.EventArgs e)
        {
            var transform = (CompositeTransform) base.RenderTransform;
            transform.CenterX = base.ActualWidth/2;
            transform.CenterY = base.ActualHeight/2;
        }

        public static readonly DependencyProperty PoiTemplateProperty =
            DependencyProperty.Register("PoiTemplate", typeof (DataTemplate), typeof (CameraPoiView), new PropertyMetadata(default(DataTemplate)));

        public DataTemplate PoiTemplate
        {
            get { return (DataTemplate) GetValue(PoiTemplateProperty); }
            set { SetValue(PoiTemplateProperty, value); }
        }

        public static readonly DependencyProperty DataProperty =
            DependencyProperty.Register("Data", typeof(object), typeof(CameraPoiView), new PropertyMetadata(default(CameraPoi)));

        public object Data
        {
            get { return (object)GetValue(DataProperty); }
            set { SetValue(DataProperty, value); }
        }
    }
}
